﻿using System;
using System.Data;
using System.ComponentModel;
using System.Reflection;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Configuration;
using System.Collections;
using System.Configuration;
using System.Web.Mail;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;

/// <summary>
/// Summary description for Common
/// </summary>
public class Common
{
	public Common()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    /// <summary>
    /// str_Type : Name of each table in Database
    /// obj_DataTable : DataTable of each page will be created automatically
    /// </summary>
    /// <param name="obj_DataTable"></param>
    /// <param name="str_Type"></param>
    public static DataTable Build_DataTable(DataTable obj_DataTable, string str_Type, string str_RowState)
    {
        if (str_RowState == "Yes")
        {
            obj_DataTable = new DataTable();
        }
        switch (str_Type)
        {
            case "News":
                {
                    if (obj_DataTable.Columns.Contains("News_ID") == false)
                    {
                        obj_DataTable.Columns.Add("News_ID", Type.GetType("System.Int32"));
                    }
                    if (obj_DataTable.Columns.Contains("News_CreateDate") == false)
                    {
                        obj_DataTable.Columns.Add("News_CreateDate", Type.GetType("System.DateTime"));
                    }
                    if (obj_DataTable.Columns.Contains("News_Content") == false)
                    {
                        obj_DataTable.Columns.Add("News_Content", Type.GetType("System.String"));
                    }
                    if (obj_DataTable.Columns.Contains("Language_ID") == false)
                    {
                        obj_DataTable.Columns.Add("Language_ID", Type.GetType("System.Int32"));
                    }
                    if (obj_DataTable.Columns.Contains("News_Active") == false)
                    {
                        obj_DataTable.Columns.Add("News_Active", Type.GetType("System.Boolean"));
                    }
                    break;
                }            
            case "Language":
                if (obj_DataTable.Columns.Contains("Language_ID") == false)
                {
                    obj_DataTable.Columns.Add("Language_ID", Type.GetType("System.Int32"));
                }
                if (obj_DataTable.Columns.Contains("Language_Name") == false)
                {
                    obj_DataTable.Columns.Add("Language_Name", Type.GetType("System.String"));
                }
                if (obj_DataTable.Columns.Contains("Language_Region") == false)
                {
                    obj_DataTable.Columns.Add("Language_Region", Type.GetType("System.String"));
                }
                if (obj_DataTable.Columns.Contains("Language_Active") == false)
                {
                    obj_DataTable.Columns.Add("Language_Active", Type.GetType("System.Boolean"));
                }
                break;            
        }
        return obj_DataTable;
    }    
}
